<!DOCTYPE html>
<html>
<head>
	<title>Big store</title>
	<!-- for-mobile-apps -->
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta property="og:title" content="Vide" />
	<meta name="keywords" content="Big store" />
	<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false);
    function hideURLbar(){ window.scrollTo(0,1); } </script>
	<!-- //for-mobile-apps -->
	<link href="css/bootstrap.css" rel='stylesheet' type='text/css' />
	<!-- Custom Theme files -->
	<link href="css/style.css" rel='stylesheet' type='text/css' />
	<!-- js -->
	<script src="js/jquery-1.11.1.min.js"></script>
	<!-- //js -->
	<!-- start-smoth-scrolling -->
	<script type="text/javascript" src="js/move-top.js"></script>
	<script type="text/javascript" src="js/easing.js"></script>
	<script type="text/javascript">
        jQuery(document).ready(function($) {
            $(".scroll").click(function(event){
                event.preventDefault();
                $('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
            });
        });
	</script>
	<!-- start-smoth-scrolling -->
	<link href="css/font-awesome.css" rel="stylesheet">

</head>
<body>
<div class="header">
	<div class="container">
		<div class="logo">
			<h1 ><a href="index.html"><b>T<br>H<br>E</b>Big Store<span>The Best Supermarket</span></a></h1>
		</div>
		<div class="head-t">
			<ul class="card">
				<li id="usercenter" style="display: none"><a class="withtoken" id="a_usercenter" href="usercenter.html" ><i class="fa fa-user" aria-hidden="true"></i>个人中心</a></li>
				<li id="login"><a class="withtoken" href="login.html" ><i class="fa fa-user" aria-hidden="true"></i>登录</a></li>
				<li id="register"><a class="withtoken" href="register.html" ><i class="fa fa-arrow-right" aria-hidden="true"></i>注册</a></li>
				<li><a class="withtoken" href="orderlist.html" ><i class="fa fa-file-text-o" aria-hidden="true"></i>订单列表</a></li>
				<li><a class="withtoken" href="wishlist.html" ><i class="fa fa-heart" aria-hidden="true"></i>收藏</a></li>
				<li><a class="withtoken" href="cart.html" ><i class="fa fa-shopping-cart" aria-hidden="true"></i>购物车</a></li>
			</ul>
		</div>
		<script type="text/javascript">
            $(function(){
                var _this1=null;
                $('.nav>li').hover(function(){
                    _this1=$(this);
                    _this1.find('.second-nav').show();
                    var _this2=null;
                    _this1.find('.second-nav').find('li').hover(function(){
                        _this2=$(this);
                        _this2.find('.third-nav').show();
                        _this2.find('.third-nav').hover(function(){
                            $(this).show();
                        },function(){
                            $(this).hide();
                        });
                    },function(){
                        _this2.find('.third-nav').hide();
                    });
                },function(){
                    _this1.find('.second-nav').hide();
                });
            });
		</script>
		<div class="nav-top">
			<nav class="navbar navbar-default">

				<div class="collapse navbar-collapse" id="bs-megadropdown-tabs">
					<ul class="nav navbar-nav ">
						<li> <!--class=" active"--> <a href="index.html" class="hyper "><span>主页</span></a></li>

						<li class="dropdown">
							<a href="#" class="dropdown-toggle  hyper" data-toggle="dropdown" >
								<span> 商品类别 <b class="caret"></b></span>
							</a>
							<ul class="dropdown-menu multi second-nav" id="dropdown-ul">
								<!---->
							</ul>
						</li>

						<li><a href="hot.html" class="hyper "><span> 热卖商品 </span></a></li>

						<li><a href="activities.html" class="hyper "><span> 促销活动 </span></a></li>

						<li><a href="contact.html" class="hyper"><span> 联系我们 </span></a></li>
					</ul>
				</div>
			</nav>

			<!--<div class="cart" >
                <span class="fa fa-shopping-cart my-cart-icon"><span class="badge badge-notify my-cart-badge"></span></span>
            </div>-->
			<div class="clearfix"></div>
		</div>

	</div>
</div>
<!---->

<!--banner-->
<div class="banner-top">
	<div class="container">
		<h3 >用户中心</h3>
		<h4><a href="index.html">Home</a><label>/</label>usercenter</h4>
		<div class="clearfix"> </div>
	</div>
</div>

<!-- contact -->
<div class="check-out">
	<div class="container">
		<div class="spec ">
			<h3>用户中心</h3>
			<div class="ser-t">
				<b></b>
				<span><i></i></span>
				<b class="line"></b>
			</div>
		</div>

		<div style="border: 1px solid lightgray;padding: 30px">
			<div id="userInfo" style="margin-top: 30px;padding: 30px">
				<a onclick="alterUserInfo()">
					<span class="label label-warning" style="font-size: 15px">编辑</span>
				</a>
				<div style="margin-top: 30px">
					地址： <p id="the_addr">上海市徐汇区虹漕路401号3号楼5楼 小寻科技</p>
					收件人： <p id="the_name">Robbin Liu</p>
					电话： <p id="the_phone">17600001234</p>
				</div>
			</div>
			<div id="alterInfo" style="margin-top: 30px;padding: 30px;display: none">
				省份：<br/>
				<input type="text" id="sheng" placeholder="省份，直辖市不填" required/>省份，直辖市不填
				<br/>
				市：<br/>
				<input type="text" id="shi" placeholder="市、县级市或直辖市" required/>市、县级市或直辖市
				<br/>
				区/县:<br/>
				<input type="text" id="xian" placeholder="区或县" required/>区或县
				<br/>
				乡/街道：<br/>
				<input type="text" id="xiang" placeholder="乡，城市不填"/>乡或街道
				<br/>
				更详细：<br/>
				<input type="text" id="other" placeholder="公司名或其他"/>公司名或其他
				<br/>
				<br/>
				收件人：<br/>
				<input type="text" id="shoujianren" placeholder="收件人"/>
				<br/>
				联系电话：<br/>
				<input type="text" id="dianhua" placeholder="联系电话"/>
				<br/>
				<br/>
				<a onclick="saveUserInfo()">
					<span class="label label-warning" style="font-size: 15px">保存</span>
				</a>
			</div>
			<script>
                //从浏览器URL获取GET请求参数
                function getQueryString(name) {
                    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
                    var r = window.location.search.substr(1).match(reg);
                    if (r != null) return unescape(r[2]); return null;
                }
                var token = getQueryString('t')==null? '':getQueryString('t');
				//console.log('token',token);
                function loadUserinfo() {
                    var responseBody = $.ajax({
                        url:"/v1/userinfo",
                        method:"GET",
                        async:false,
                        headers:{
                            t:token
                        }
                    });
                    console.log('order',responseBody);
                    if(responseBody.status == 444){
                        alert('session bad');
                        window.location='login.html';
                    }else if(responseBody.status==200){
                        var userinfo = responseBody.responseJSON;
                        document.getElementById('the_addr').innerHTML = userinfo.addr_sheng + userinfo.addr_shi
							+ userinfo.addr_qu_xian + userinfo.addr_xiang_jiedao + "  " + userinfo.addr_other;
                        document.getElementById('the_name').innerHTML = userinfo.name;
                        document.getElementById('the_phone').innerHTML = userinfo.phone;

                        document.getElementById('sheng').value = userinfo.addr_sheng;
                        document.getElementById('shi').value = userinfo.addr_shi;
                        document.getElementById('xian').value = userinfo.addr_qu_xian;
                        document.getElementById('xiang').value = userinfo.addr_xiang_jiedao;
                        document.getElementById('other').value = userinfo.addr_other;
                        document.getElementById('shoujianren').value = userinfo.name;
                        document.getElementById('dianhua').value = userinfo.phone;
                    }
                }
                loadUserinfo();

                function saveUserinfo() {
                    var user_sheng = document.getElementById('sheng').value;
                    var user_shi = document.getElementById('shi').value;
                    var user_xian = document.getElementById('xian').value;
                    var user_xiang = document.getElementById('xiang').value;
                    var user_other = document.getElementById('other').value;
                    var user_shoujianren = document.getElementById('shoujianren').value;
                    var user_dianhua = document.getElementById('dianhua').value;

                    if(user_sheng == '' || user_sheng == undefined) {alert('省份必填'); return;}
                    if(user_shi == '' || user_shi == undefined) {alert('市必填'); return;}
                    if(user_xian == '' || user_xian == undefined) {alert('区/县必填'); return;}
                    if(user_xiang == '' || user_xiang == undefined) {alert('乡/街道必填'); return;}
                    if(user_other == '' || user_other == undefined) {alert('详细地址必填'); return;}

                    if(user_shoujianren == '' || user_shoujianren == undefined) {alert('收件人必填'); return;}
                    if(user_dianhua == '' || user_dianhua == undefined) {alert('联系电话必填'); return;}

                    var responseBody = $.ajax({
                        url:"/v1/userinfo",
                        method:"POST",
                        async:false,
						data:{
                            "addr_sheng":user_sheng,
							"addr_shi":user_shi,
							"addr_qu_xian":user_xian,
							"addr_xiang_jiedao":user_xiang,
							"addr_other":user_other,
							"name":user_shoujianren,
							"phone":user_dianhua
						},
                        headers:{
                            t:token
                        }
                    });
                    //console.log('userinfo',responseBody);
                    if(responseBody.status == 444){
                        alert('session bad');
                        window.location='login.html';
                    }else if(responseBody.status==200){
                        loadUserinfo();
                    }
                }
                var alterInfo = document.getElementById('alterInfo');
                var userInfo = document.getElementById('userInfo');
				function alterUserInfo() {
                    alterInfo.style.display='block';
                    userInfo.style.display='none';
                }
                function saveUserInfo() {
                    alterInfo.style.display='none';
                    userInfo.style.display='block';
                    saveUserinfo();
                }
			</script>
		</div>
	</div>
</div>


<!--footer-->
<div class="footer">
	<div class="container">
		<div class="col-md-3 footer-grid">
			<h3>About Us</h3>
			<p>Big Store 是阿里巴巴集团全力打造的网上超市。Big Store 为广大网购消费者提供进口食品、食品饮料、粮油副食、美容洗护、家居用品、家庭清洁、
				母婴用品等所有生活必需品，商品品质100%保证。随时随地，轻松用手机或鼠标逛超市，生活快消品一次性购齐，不用排队、送货上门，
				还提供7天无理由退货服务。Big Store，让生活更简单。</p>
		</div>

		<div class="col-md-2 footer-grid "></div>

		<div class="col-md-3 footer-grid ">
			<h3>Menu</h3>
			<ul>
				<li><a href="index.html">主页</a></li>
				<li><a href="hot.html">热卖商品</a></li>
				<li><a href="activities.html">促销活动</a></li>
				<li><a href="contact.html">联系我们</a></li>
			</ul>
		</div>

		<div class="col-md-3 footer-grid">
			<h3>My Account</h3>
			<ul>
				<li><a href="login.html">登录</a></li>
				<li><a href="register.html">注册</a></li>
				<li><a href="wishlist.html">收藏</a></li>
				<li><a href="cart.html">购物车</a></li>
			</ul>
		</div>
		<div class="clearfix"></div>

		<div class="copy-right">
			<p> &copy; 2018 Big store. All Rights Reserved </p>
		</div>
	</div>
</div>
<!-- //footer-->
<script src="js/header_category.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        loadUserName(token);
        var alist = document.getElementsByTagName('a');
        console.log('alist', alist);
        for (i = 0; i < alist.length; i++) {
            var hrefstr = alist[i].getAttribute('href');
            if(hrefstr == null){
                continue;
            }
            //console.log('hrefstr', hrefstr);
            if(hrefstr.indexOf('?')>0){
                hrefstr = hrefstr +'&t='+token;
            }else{
                hrefstr = hrefstr +'?t='+token;
            }
            alist[i].setAttribute('href', ''+hrefstr);
        }


        $().UItoTop({ easingType: 'easeOutQuart' });
    });
</script>
<a href="#" id="toTop" style="display: block;"> <span id="toTopHover" style="opacity: 1;"> </span></a>


</body>
</html>